home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
026-050
/
scopedisk42
/
extractfont12
/
extractfont.doc
< prev
next >
Wrap
Text File
|
1995-03-18
|
4KB
|
141 lines
EXTRACTFONT 1.2 (see note at bottom of docs)
This program will take any standard Amiga font and
create a C Source file so that the font may be used
without having to appear in the user's FONTS:
directory.
I personally feel this is the way most programs
should operate. The Only programs that should require
fonts in the FONTS: directory are programs that let
the user choose and use fonts (ie. Graphics and
WYSIWYG style Word Processing programs.)
The problem with programs that require certain fonts
in the user's FONTS: directory are two fold. First,
if every program needs a specific font in the user's
FONTS: directory that directory could get very large
and too large for even one disk. Second, many users
including myself boot from many different boot disks
and it is unreasonable to force the user to either put
your fonts on each of his boot disks or to always boot
from a particular disk when running your program.
Enter EXTRACTFONT. The program will take any
standard Amiga font and create a C source file that
you can compile and link with your program so that
your fonts are part of your program.
I have included an example program. TEST.c TEST.c
links with a file called SMALL.c that was generated
with EXTRACTFONT. TEST.c opens a window and prints
some text into that window with the SMALL.font. Most
program will work this way.
If you have a multi-tasking type program that needs
to use the same font across tasks then you must
allocate PUBLIC memory and copy the font to this
public memory. Then call AddFont() to make the font
part of the System's list of fonts. To use it in
other tasks just call OpenFont and not OpenDiskFont
since it is already in memory. Aternatively, if you
other tasks/programs open screens just set the
NewScreen.Font to point to a valid TextAttr structure
for your font and your screen will be using the font.
When you are done with the font you can call RemFont()
to remove it from the System's list of fonts.
Example of multi-program font use.
Master Program---
...
/* Font data */
extern struct TextFont SmallFont;
struct TextFont *MainFont = 0;
if (!( MainFont = AllocMem (SmallFont.tf_Message.mn_Length, MEMF_PUBLIC)))
Quit ("Couldn't allocate memory for font");
CopyMem (&SmallFont, MainFont, SmallFont.tf_Message.mn_Length);
AddFont (MainFont);
/* Startup subordinate task or program */
/* When all subordinate tasks and programs are done as and
you are ready to exit... */
if (MainFont) RemFont (MainFont);
....
Subordinate Program
....
struct Screen *MainScreen = 0;
struct TextAttr NormFont = {
(UBYTE *)"small.font", /* Font Name */
5, /* Font Height */
FS_NORMAL, /* Style */
FPF_DESIGNED }; /* Preferences */
struct NewScreen NewScreen = {
0, 0, /* Left, Top Edge */
320,200, /* Width, Height */
5, /* Depth */
0, 0, /* DetailPen, BlockPen */
NULL, /* Display Modes */
CUSTOMSCREEN|CUSTOMBITMAP, /* Screen Type */
&NormFont, /* Font */
NULL, /* Title */
NULL, /* Screen Gadgets */
NULL, /* CustomBitMap */
};
MainScreen = OpenScreen (&NewScreen);
/* Screen and therefore all windows on this screen are now using the your
font. */
----or----
struct TextFont *YourFont = 0;
struct TextAttr NormFont = {
(UBYTE *)"small.font", /* Font Name */
5, /* Font Height */
FS_NORMAL, /* Style */
FPF_DESIGNED }; /* Preferences */
YourFont = OpenFont (&NormFont);
/* Now you can set your RastPort(s) to use the font */
SetFont (YourRastPort, YourFont);
/* When your done and exiting this task/program you must */
CloseFont (YourFont);
Good Luck!
Gregg Tavares
3332 Mentone Ave #8
Los Angeles, CA 90034
CIS: 72411,2772
PeopleLink: GreggT
Note: The orignal version of this program had a
"bug". I had assumed (don't ask me why) that all
fonts required Space and Kern fields even if they
were Fixed-Width fonts. Well I was wrong. That
assumption has been fixed and the program should now
work with all your fonts. (excluding ColorFonts).
Also, someone (sorry I forgot to note your name)
suggested I make many of the font parts "static" so
that you can include many fonts in one program
without having to edit the 'C' source files created
by EXTRACTFONT. Well I had added this suggestion and
it works well. Thank you to whomever suggested it.